package view 
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display3D.textures.Texture;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.net.URLRequest;
	
	public class Building extends Sprite
	{
		
		public function Building(_url:String)
		{
			url=_url
			addBuilding();
			
		}
		/**
		 *箭塔 
		 */		
		private var building:Loader;
		/**
		 * 箭塔图片的路径
		 */		
		public var url:String;
		/**
		 *建造箭塔 
		 * 
		 */		
		private function addBuilding():void
		{
			if(!building)
			{
				building = new Loader();
				addChild(building)
			}
			building.load(new URLRequest(url));
			building.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
			
			
		}
		
		protected function loaded(event:Event):void
		{
			
			building.x = -building.content.width/2
			building.y = -building.content.height/2
		}
	}
}